unit WeighSetting;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, BaseDialog, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters,
  Menus, StdCtrls, cxButtons, ExtCtrls, cxControls, cxContainer, cxEdit,
  dxSkinsCore, dxSkinsDefaultPainters, cxMaskEdit, cxDropDownEdit,
  cxTextEdit, cxLabel, IniFiles, GlobalVar, MisString, dxSkinsForm;

type
  TfrmWeighSetting = class(TfrmBaseDialog)
    cxLabel1: TcxLabel;
    edtStart: TcxTextEdit;
    cxLabel2: TcxLabel;
    cxLabel3: TcxLabel;
    cxLabel4: TcxLabel;
    cxLabel5: TcxLabel;
    cxLabel6: TcxLabel;
    cxLabel7: TcxLabel;
    edtComPort: TcxComboBox;
    edtBaud: TcxComboBox;
    edtEnd: TcxTextEdit;
    Label11: TLabel;
    Label1: TLabel;
    edtCheck: TcxComboBox;
    edtData: TcxComboBox;
    edtStop: TcxComboBox;
    btnDefault: TcxButton;
    pmDefault: TPopupMenu;
    DSD1001: TMenuItem;
    procedure DSD1001Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmWeighSetting: TfrmWeighSetting;

implementation

{$R *.dfm}

procedure TfrmWeighSetting.DSD1001Click(Sender: TObject);
begin
  inherited;
  edtComPort.ItemIndex := edtComPort.Properties.Items.IndexOf('COM1');
  edtBaud.ItemIndex := edtBaud.Properties.Items.IndexOf('4800');
  edtCheck.ItemIndex := edtCheck.Properties.Items.IndexOf('NONE');
  edtData.ItemIndex := edtData.Properties.Items.IndexOf('8');
  edtStop.ItemIndex := edtStop.Properties.Items.IndexOf('1');
  edtStart.Text := '02';
  edtEnd.Text := '0D';
end;

procedure TfrmWeighSetting.FormCreate(Sender: TObject);
var
  ReadIni: TIniFile;
begin
  inherited;
  ReadIni := TIniFile.Create(GetAppDirectory + g_sAppIniFile);
  try
    edtComPort.ItemIndex := ReadIni.ReadInteger('WeighSet', 'ComPort', 1) - 1;
    edtBaud.ItemIndex := edtBaud.Properties.Items.IndexOf(IntToStr(ReadIni.ReadInteger('WeighSet', 'BaudRate', 4800)));
    edtData.ItemIndex := edtData.Properties.Items.IndexOf(IntToStr(ReadIni.ReadInteger('WeighSet', 'Len', 8)));
    edtCheck.ItemIndex := edtData.Properties.Items.IndexOf(IntToStr(ReadIni.ReadInteger('WeighSet', 'Len', 8)));
//    chkDynFind.Checked := ReadIni.ReadBool('WeighSet', 'ComPort', 1);
//    chkLately.Checked := ReadIni.ReadBool('WeighSet', 'Lately', False);
//    chkHappen.Checked := ReadIni.ReadBool('WeighSet', 'Happen', False);
//    chkTraderProduct.Checked := ReadIni.ReadBool('WeighSet', 'TraderProduct', False);
//    chkDepotQty.Checked := ReadIni.ReadBool('WeighSet', 'Depot', False);
//    chkShowPic.Checked := ReadIni.ReadBool('WeighSet', 'ShowPic', False);
  except
  end;
  FreeAndNil(ReadIni);
end;

procedure TfrmWeighSetting.btnOKClick(Sender: TObject);
var
  SaveIni: TIniFile;
begin
  inherited;
  SaveIni := TIniFile.Create(GetAppDirectory + g_sAppIniFile);
  try
//    SaveIni.WriteBool('WeighSet', 'DynFind', chkDynFind.Checked);
//    SaveIni.WriteBool('WeighSet', 'Lately', chkLately.Checked);
//    SaveIni.WriteBool('WeighSet', 'Happen', chkHappen.Checked);
//    SaveIni.WriteBool('WeighSet', 'TraderProduct', chkTraderProduct.Checked);
//    SaveIni.WriteBool('WeighSet', 'Depot', chkDepotQty.Checked);
//    SaveIni.WriteBool('WeighSet', 'ShowPic', chkShowPic.Checked);
  except
  end;
  FreeAndNil(SaveIni);
end;

end.

